package com.gduf.lsm.mapper;

import com.gduf.lsm.common.annotation.AutoFill;
import com.gduf.lsm.common.enums.OperationType;
import com.gduf.lsm.entity.Activity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author lsm
 * @Data
 * 公益活动
 */
@Mapper
public interface ActivityMapper {
    /**
     * 新增
     * @param activity
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    int insert(Activity activity);

    /**
     * 删除
     * @param id
     * @return
     */
    int deleteById(Integer id);

    /**
     * 修改
     * @param activity
     * @return
     */
    @AutoFill(value = OperationType.UPDATE)
    int updateById(Activity activity);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from activity where id=#{id}")
    Activity selectById(Integer id);

    /**
     * 查询所有（模糊查询，分页）
     * @param activity
     * @return
     */
    List<Activity> selectAll(Activity activity);

    /**
     * 根据分类名查询分类
     * @param title
     * @return
     */
    @Select("select * from activity where name=#{name}")
    Activity selectByName(String title);

    /**
     * 统计数量
     * @return
     */
    @Select("select count(id) from activity")
    int countAll();
}
